""" Example of using one of the OWLS ionization balance tables. """

import owls_cloudy_ion_table as ocit
import numpy as np
import matplotlib.pyplot as plt


# first initialize a table for a given ion
#-----------------------------------------------
itab = ocit.IonTableOWLS( 'h1.hdf5' )


# then choose a redshift and set iz
#-----------------------------------------------
z = 2.0
itab.set_iz( z )


# now we can interpolate the table for the 
# ionization balance at a given density and 
# temperature (nH and T should be input in log) 
#-----------------------------------------------

log_nH = np.linspace( -6.0, 1.0, 100 )
log_T = np.ones( len(log_nH) ) * 4.0

x = itab.interp( log_nH, log_T )



plt.plot( log_nH, np.log10( x ) )
